home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 35 / Amiga Format AFCD35 (Issue 119, Jan 1999).iso / -in_the_mag- / reader_requests / fredobbutils / bbsrc / mouseaccelbb.s < prev    next >
Text File  |  1998-11-06  |  6KB  |  275 lines

  1. * Bootblock spécial: Mouse acceleration using input.device
  2. * Coded by Frédéric Bassaler (June 1996)
  3.  
  4.     Incdir    asm:/Include/
  5.     Include equ.s
  6.     include    exec/types.i
  7.     include    exec/interrupts.i
  8.  
  9. DEFXFACT=8    ;facteur d'accélération par défaut (default accel. factor)
  10.  
  11. ;DBUG=0    ;comment this to disable debug mode
  12.  
  13. Start:
  14.     IFND    DBUG
  15.     dc.b    "DOS",0
  16.     dc.l    0,$370
  17.     ENDC
  18. Main:
  19.     btst    #6,$bfe001    ;test leftmousebutton
  20.     beq.w    Init
  21.  
  22. * allocate buffer for variables
  23.     movem.l    d0-a6,-(sp)
  24.     move.l    #VARSIZE,d0
  25.     move.l    #$10002,d1    ;chip+clear
  26.     IFD    DBUG
  27.     move.l    4.w,a6
  28.     ENDC
  29.     jsr    AllocMem(a6)
  30.     move.l    d0,a5
  31. * allouer mémoire pour la structure input-handler
  32.     moveq    #IS_SIZE,d0
  33.     move.l    #$10001,d1
  34.     jsr    AllocMem(a6)
  35.     move.l    d0,handler(a5)
  36. * allouer mémoire pour le programme proprement dit
  37. * du nouvel input-handler (is_code)
  38.     moveq    #CODESIZE,d0
  39.     moveq    #$1,d1
  40.     jsr    AllocMem(a6)
  41.     move.l    d0,handlercode(a5)
  42.  
  43. * copier les données RAW gfx vers bitplane
  44. * (show a little graphic)
  45.     lea    planes(a5),a2        ;adr bitplane
  46.     lea    rawgfx(pc),a0    ;source: raw gfx data
  47.     lea    40*60+10(a2),a2    ;YStart=60
  48.     moveq    #5-1,d7    ;nbre de lignes
  49. .cop0
  50.     move.l    a2,a1
  51.     moveq    #16-1,d0    ;nbre d'octets/ligne
  52. .cop    move.b    (a0)+,(a1)+
  53.     dbf    d0,.cop
  54.     lea    40(a2),a2    ;ligne suivante
  55.     dbf    d7,.cop0
  56.  
  57.     lea    $dff000,a4
  58.     move    2(a4),olddma(a5)
  59.     or    #$8400,olddma(a5)
  60.     move    #$7fff,$96(a4)    ;dma off
  61.     lea    coplist(pc),a1
  62. * adresse des bitplanes
  63.     lea    planes(a5),a2
  64.     move.l    a2,d0
  65.     move    d0,lo1-coplist(a1)
  66.     swap    d0
  67.     move    d0,hi1-coplist(a1)
  68. * copier copperlist ds buffer
  69.     lea    mycop(a5),a2
  70.     move.l    a2,a3
  71.     moveq    #(COPSIZE/4)-1,d0
  72. .copy
  73.     move.l    (a1)+,(a2)+
  74.     dbf    d0,.copy
  75.  
  76.     move.l    a3,$80(a4)
  77.     clr    $88(a4)
  78.     move    #%1000001111000000,$96(a4)    ;mon dma
  79.  
  80. * attendre n 50e de sec.
  81.     move.l    $9c(a6),a6
  82.     moveq    #50,d7
  83. .w
  84.     jsr    WaitTOF(a6)
  85.     dbf    d7,.w
  86.  
  87.     IFD    DBUG
  88.     move.l    4.w,a6
  89.     bra    FreeHandler
  90.     ENDC
  91.  
  92. * créer un msgport
  93.     lea    readreply(a5),a1
  94.     move.l    a1,d7
  95.     move.l    4.w,a6
  96.     move.l    276(a6),$10(a1)        ;execbase->ThisTask
  97.     jsr    AddPort(a6)
  98. * ouvrir dev. input
  99. OpenDev:
  100.     lea    inputio(a5),a1        ;struct iostreq
  101.     move.l    d7,14(a1)        ;msg port
  102.     moveq    #0,d0            ;unit
  103.     moveq    #0,d1            ;flags
  104.     lea    inputname(pc),a0    ;device name
  105.     jsr    OpenDevice(a6)
  106.     tst.l    d0
  107.     bne.b    FreeHandler        ;si erreur
  108.  
  109. * installation du nouvel input handler
  110. AddInputHandler:
  111.     move.l    handler(a5),a0
  112. ;    move.b    #2,ln_type(a0)    ;type: interrupt
  113. ;    move.b    #51,ln_pri(a0)
  114.     move    #$0233,LN_TYPE(a0)
  115.     move.l    handlercode(a5),a1
  116.     move.l    a1,IS_CODE(a0)
  117.  
  118.     lea    NewHandlerCode(pc),a2
  119.     moveq    #CODESIZE-1,d0
  120. .copy    move.b    (a2)+,(a1)+
  121.     dbf    d0,.copy
  122.  
  123.     lea    inputio(a5),a1
  124.     move    #9,28(a1)    ;IND_ADDHANDLER
  125.     move.l    a0,40(a1)    ;io_data: Handler
  126.     jsr    DoIO(a6)
  127. .closedev
  128.     lea    inputio(a5),a1
  129.     move.l    14(a1),-(sp)
  130.     jsr    CloseDevice(a6)
  131.     move.l    (sp)+,a1
  132.     jsr    RemPort(a6)
  133.     bra.s    CloseAll
  134.  
  135. FreeHandler:
  136.     move.l    handlercode(a5),a1
  137.     moveq    #CODESIZE,d0
  138.     jsr    FreeMem(a6)
  139. CloseAll:
  140.     move.l    a5,a1
  141.     move.l    #VARSIZE,d0
  142.     jsr    FreeMem(a6)
  143.  
  144. restore
  145. ;    move    #$7fff,$96(a4)
  146.     move.l    $9c(a6),a0    ;execbase->gfxbase
  147.     move.l    38(a0),$80(a4)
  148.     clr    $88(a4)
  149.     move    olddma(a5),$96(a4)
  150.  
  151.     movem.l    (sp)+,d0-a6
  152. Init:
  153.     lea    dosname(pc),a1
  154.     IFD    DBUG
  155.     move.l    4.w,a6
  156.     ENDC
  157.     jsr    FindResident(a6)
  158.     move.l    d0,a0
  159.     move.l    22(a0),a0
  160.     moveq    #0,d0
  161.     rts
  162.  
  163. ;RemInputHandler:
  164. ;    lea    inputio(pc),a1
  165. ;    move    #10,28(a1)    ;IND_REMHANDLER
  166. ;    lea    NewHandler(pc),a0
  167. ;    move.l    a0,40(a1)    ;io_data: adr handler
  168. ;do_io    move.l    4.w,a6
  169. ;    jmp    DoIO(a6)
  170.  
  171. *** Datas à installer en mémoire: nouvel input handler
  172. ;NewHandler:
  173. ;    dc.l    0,0    ;ln_succ,ln_pred
  174. ;    dc.b    2    ;ln_type: nt_interrupt
  175. ;    dc.b    51    ;ln_pri
  176. ;    dc.l    NewHandlerName ;ln_name
  177. ;    dc.l    NewHandlerData,NewHandlerCode    ;is_data, is_code
  178. ;NewHandlerName    dc.b "MouseAccel boot v1.0 by F.BASSALER",0
  179. ;NewHandlerData:
  180.  
  181. *** Programme du Handler
  182. NewHandlerCode:
  183.     movem.l    d0-a6,-(sp)
  184.     move.b    4(a0),d2    ;ie_class
  185.     cmp.b    #2,d2        ;rawmouse?
  186.     beq.b    .mousemov
  187.     cmp.b    #1,d2        ;rawkey?
  188.     bne.b    .no
  189.     movem    6(a0),d0-d1    ;ie_code, ie_qualifier
  190.     cmp.b    #$10,d1        ;left ALT
  191.     bne.b    .no
  192.     and    #$ff,d0
  193.     sub.b    #$50,d0
  194. ;    tst.b    d0
  195.     bcs.b    .no
  196.     cmp.b    #7,d0
  197.     bhi.b    .no
  198.     addq    #1,d0
  199.     lea    xfact(pc),a1
  200.     move    d0,(a1)        ;->accel.
  201.     bra.b    .no
  202. .mousemov
  203.     movem    10(a0),d0-d1    ;deltaX, deltaY
  204. * on accélère !
  205.     moveq    #0,d7
  206.     move    xfact(pc),d7    ;facteur d'accel.
  207.     muls    d7,d0
  208.     muls    d7,d1
  209.     movem    d0-d1,10(a0)
  210. .no
  211.     movem.l    (sp)+,d0-a6
  212.     move.l    a0,d0
  213.     rts
  214. xfact    dc.w DEFXFACT    ;facteur d'accélération
  215.  
  216. NewHandlerEnd:
  217. CODESIZE=*-NewHandlerCode
  218.  
  219. *** DATA
  220. LORES=%0001001000000000        ;ajuster le nbre de bitplanes
  221. HIRES=LORES!$8000
  222. LACE=4
  223.  
  224. coplist:
  225.  DC.w $0100,LORES
  226.  dc.w $008E,$2981
  227.  DC.w $0090,$29c1
  228.  dc.w $0092,$0038
  229.  DC.w $0094,$00d0
  230.  dc.w $0180,$000
  231.  dc.w $0182,$fff
  232.  dc.w $00e0
  233. hi1:dc.w 0
  234.  dc.w $00e2
  235. lo1:dc.w 0
  236.  dc.w $FFFF,$FFFE    ;fin de la liste copper
  237. COPSIZE=*-coplist
  238.  
  239. * données IFF converties en RAW par GFXCONV
  240. rawgfx:
  241.     DC.B    $89,$92,$6F,$31,$CE,$F4,$04,$18
  242.     DC.B    $39,$10,$F3,$8C,$66,$64,$7B,$80
  243.     DC.B    $DA,$52,$88,$4A,$10,$84,$0C,$24
  244.     DC.B    $24,$A0,$82,$52,$88,$94,$42,$40
  245.     DC.B    $AA,$52,$4E,$7A,$10,$E4,$04,$24
  246.     DC.B    $38,$40,$E3,$9E,$44,$F4,$73,$80
  247.     DC.B    $8A,$52,$28,$4A,$10,$84,$04,$24
  248.     DC.B    $24,$40,$82,$52,$22,$94,$42,$40
  249.     DC.B    $89,$8C,$CF,$49,$CE,$F7,$0E,$98
  250.     DC.B    $38,$40,$8B,$92,$CC,$97,$7A,$40
  251. rawsize=*-rawgfx
  252.  
  253. inputname    dc.b "input.device",0
  254. dosname        dc.b "dos.library",0
  255.  
  256.  dc.b " MOUSE-ACCELERATOR BOOT 1.0 BY F.B - "
  257.  DC.B "PRESS <LMB> DURING BOOT TO CANCEL INSTALLATION. "
  258.  dc.b "USE THE LEFT ALT KEY + F1...F8 TO CHANGE ACCEL.FACTOR. "
  259.  DC.B "FOR CODING-SWAPPING IDEAS & BOOTPRGS, WRITE TO: "
  260.  DC.B "FREDERIC BASSALER - LA SERRE - 19500 COLLONGES - FRANCE"
  261.  dc.b ". SPREAD THIS BOOTBLOCK!!"
  262.  
  263. End:
  264.     dcb.b    512*2,0
  265.  
  266.     rsreset
  267. handler        rs.l    1
  268. handlercode    rs.l    1
  269. olddma        rs.w    1
  270. inputio         rs.b    48
  271. readreply     rs.b    34
  272. planes        rs.b    (320/8)*256
  273. mycop        rs.b    COPSIZE
  274. VARSIZE        rs.w    0
  275.